/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package sk.robocup.dvanastyhrac.tactics;

import java.util.ArrayList;

import robocup.component.PConf;
import robocup.component.coach.PlayerTypeAnalyzer;
import robocup.component.geometry.Vektor;
import robocup.component.tactics.FormationData;
import robocup.component.worldobjects.Player.ROLE;
import sk.robocup.dvanastyhrac.tactics.formation.PlayerFormationInfo12;
import sk.robocup.dvanastyhrac.tactics.formation.PlayerFormationInfo12.FORMATION;

/**
 * A class containing all start positions.
 */
public class FormationData12 extends FormationData {

	/**
	 * This method retrieves the Start-Position of a player depending on his
	 * player's role.
	 * 
	 * @param role - the players role
   * @param selfKickOff - true when it's our kick off, false otherwise
	 * @return a vektor containing the position
	 */
	public static double SIZE_OF_MOVE = 30.0;
	public static double PITCH_WIDTH = 68.0;
	public static double PITCH_LENGTH = 105.0;
	public static double PENALTY_AREA_LENGTH = 16.5;
	public static double PENALTY_Y = PITCH_LENGTH / 2.0 - PENALTY_AREA_LENGTH;
	public static FORMATION currentFormation = FORMATION.ATTACK;
	public static ArrayList<ArrayList<PlayerFormationInfo12>> formationList = new ArrayList<ArrayList<PlayerFormationInfo12>>();
	
	static
	{
	 ArrayList<PlayerFormationInfo12> attackList = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(attackList);
	 //goalie
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -50), false, 0, 0, 0, 0));	 	
	 // number 2
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -15, -16.5), false, 2, -45, 0.25, 0.7));	 	
	// number 3
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, -21), true, 2, -42, 0.2, 0.5));	 		
	// number 4
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 15, -16.5), true, 2, -47, 0.4, 0.5));	 	
	// number 5
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -5, -15), false, 2, -45, 0.25, 0.7));	 	
	// number 6
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -11, 0), false, 20, -26, 0.3, 0.65));	 	
	// number 7
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 11, 0), false, 20, -26, 0.25, 0.7));	 	
	// number 8
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, 20), false, 35, -5, 0.3, 0.5));
	// number 9
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -5, 20), false, 35, -5, 0.25, 0.6));
	// number 10
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -19, 30), false, 45, -5, 0, 0.7));
	// number 11
	 attackList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 19, 30), false, 45,-5, 0, 0.7));	 	

	 ArrayList<PlayerFormationInfo12> defenseList = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(defenseList);
	 //goalie
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -45), false, 0, 0, 0, 0));	 	
	 // number 2
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -21, -22), true, 2, -45, 0.2, 0.4));	 	
	// number 3
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -5, -30), true, 2, -45, 0.25, 0.5));	 		
	// number 4
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, -30), true, 2, -45, 0.25, 0.5));	 	
	// number 5
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 21, -22), true, 2, -45, 0.2, 0.4));	 	
	// number 6
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 24, 1), false, 25, -30, 0.3, 0.6));	 	
	// number 7
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -8, -5), false, 25, -30, 0.15, 0.5));	 	
	// number 8
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 8, -5), false, 30, -5, 0.25, 0.5));
	// number 9
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -24, 1), false, 30, -5, 0.3, 0.6));
	// number 10
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -7, 18), false, 30, -5, 0.5, 0.7));
	// number 11
	 defenseList.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 7, 18), false, 30, -5, 0.5, 0.7));
	 
	 
	 //specialne taktiky na zaklade evolucnych metod
	 ArrayList<PlayerFormationInfo12> attackList1 = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(attackList1);
	 //goalie
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -50), false, 0, 0, 0, 0));	 	
	 // number 2
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 13, -45), false, 10, -45, 0.25, 0.7));	 	
	// number 3
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, -40), true, 10, -42, 0.2, 0.5));	 		
	// number 4
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -9, -25), true, 10, -47, 0.4, 0.5));	 	
	// number 5
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 12, -28), false, 20, -20, 0.25, 0.7));	 	
	// number 6
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 3, -12), false, 42, -10, 0.3, 0.65));	 	
	// number 7
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -13, 0), false, 42, -10, 0.25, 0.7));	 	
	// number 8
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 24, 0), false, 44, 10, 0.3, 0.5));
	// number 9
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -20, 10), false, 44, 10, 0.25, 0.6));
	// number 10
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -8, 25), false, 45, 10, 0.5, 0.7));
	// number 11
	 attackList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 15, 35), false, 45, 10, 0.5, 0.7));	 	

	 ArrayList<PlayerFormationInfo12> defenseList1 = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(defenseList1);
	 //goalie
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -45), false, 0, 0, 0, 0));	 	
	 // number 2
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -7, -30), true, 0, -45, 0.2, 0.4));	 	
	// number 3
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -18, -20), true, 0, -45, 0.25, 0.5));	 		
	// number 4
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 15, -17), true, 0, -45, 0.25, 0.5));	 	
	// number 5
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, -10), true, 15, -45, 0.2, 0.4));	 	
	// number 6
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -1, -2), false, 15, -30, 0.3, 0.6));	 	
	// number 7
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 10, -1), false, 15, -30, 0.15, 0.5));	 	
	// number 8
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -24, 20), false, 30, 10, 0.25, 0.5));
	// number 9
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -10, 24), false, 30, 10, 0.3, 0.6));
	// number 10
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 10, 30), false, 35, 10, 0.5, 0.7));
	// number 11
	 defenseList1.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -20, 40), false, 45, 10, 0.5, 0.7));
	 
	 
	//agresivne taktiky pre obranu a utok
	 ArrayList<PlayerFormationInfo12> attackList2 = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(attackList2);
	 //goalie
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -50), false, 0, 0, 0, 0));	 	
	 // number 2
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -12, 0), false, 2, -45, 0.25, 0.7));	 	
	// number 3
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, 0), true, 2, -42, 0.2, 0.5));	 		
	// number 4
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 16, 0), true, 2, -47, 0.4, 0.5));	 	
	// number 5
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -20, 25), false, 25, -45, 0.5, 0.7));	 	
	// number 6
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -10, 25), false, 25, 0, 0.3, 0.65));	 	
	// number 7
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 10, 25), false, 25, 0, 0.3, 0.7));	 	
	// number 8
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 20, 25), false, 35, 5, 0.1, 0.5));
	// number 9
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, 35), false, 45, 5, 0.1, 0.6));
	// number 10
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -15, 35), false, 45, 0, 0.5, 0.7));
	// number 11
	 attackList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 15, 35), false, 45, 0, 0.5, 0.7));	 	

	 ArrayList<PlayerFormationInfo12> defenseList2 = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(defenseList2);
	 //goalie
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -45), false, 0, 0, 0, 0));	 	
	 // number 2
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -10, -40), true, 5, -45, 0.2, 0.4));	 	
	// number 3
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -40), true, 5, -45, 0.25, 0.5));	 		
	// number 4
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 9, -40), true, 5, -45, 0.25, 0.5));	 	
	// number 5
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -15, -30), true, 20, -45, 0.2, 0.4));	 	
	// number 6
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -5, -20), false, 20, -30, 0.3, 0.6));	 	
	// number 7
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 15, -30), false, 20, -30, 0.15, 0.5));	 	
	// number 8
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, -10), false, 30, -30, 0.25, 0.5));
	// number 9
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -12, 0), false, 45, -20, 0.3, 0.6));
	// number 10
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -10), false, 45, -20, 0, 0.7));
	// number 11
	 defenseList2.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 12, 0), false, 45, -20, 0, 0.7));
	 
	 //Taktiky ATTACK1 a DEFENSE1
	 ArrayList<PlayerFormationInfo12> attackList3 = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(attackList3);
	 //goalie
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -50), false, 0, 0, 0, 0));	 	
	 // number 2
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -15, -16.5), false, 2, -45, 0.25, 0.7));	 	
	// number 3
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, -21), true, 2, -42, 0.2, 0.5));	 		
	// number 4
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 15, -16.5), true, 2, -27, 0.4, 0.5));	 	
	// number 5
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -5, -21), false, 2, -25, 0.25, 0.7));	 	
	// number 6
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -11, 0), false, 30, -26, 0.3, 0.65));	 	
	// number 7
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 11, 0), false, 30, -26, 0.25, 0.7));	 	
	// number 8
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, 25), false, 45, -5, 0.3, 0.5));
	// number 9
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -5, 25), false, 45, -5, 0.25, 0.6));
	// number 10
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -19, 35), false, 45, -5, 0, 0.7));
	// number 11
	 attackList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 19, 35), false, 45,-5, 0, 0.7));	 	

	 ArrayList<PlayerFormationInfo12> defenseList3 = new ArrayList<PlayerFormationInfo12>();
	 formationList.add(defenseList3);
	 //goalie
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -45), false, 0, 0, 0, 0));	 	
	 // number 2
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -18, -22), true, 2, -45, 0.2, 0.4));	 	
	// number 3
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -5, -30), true, 2, -45, 0.25, 0.5));	 		
	// number 4
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 5, -30), true, 2, -45, 0.25, 0.5));	 	
	// number 5
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 18, -22), true, 2, -45, 0.2, 0.4));	 	
	// number 6
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 24, 1), false, 25, -30, 0.3, 0.6));	 	
	// number 7
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -25), false, 25, -30, 0.15, 0.5));	 	
	// number 8
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 0, -15), false, 30, -15, 0.25, 0.5));
	// number 9
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -24, 1), false, 30, -25, 0.3, 0.6));
	// number 10
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, -7, 5), false, 30, -5, 0.5, 0.7));
	// number 11
	 defenseList3.add(new PlayerFormationInfo12(new Vektor(Vektor.XY, 7, 5), false, 30, -5, 0.5, 0.7));
	 
	 
	} 
	
	
	public static Vektor getStartPosition(ROLE role, boolean selfKickOff) {

		int xy = Vektor.XY;

		switch (role) {
		case GOALIE:
			return new Vektor(xy, 0.0, -50);
		case INLE_BACK_FOUR:
			return new Vektor(xy, -7.0, -15.0);
		case INRE_BACK_FOUR:
			return new Vektor(xy, 7.0, -15.0);
		case LEFT_BACK_FOUR:
			return new Vektor(xy, -20.0, -15.0);
		case RIGHT_BACK_FOUR:
			return new Vektor(xy, 20.0, -15.0);
		case CENTER_MIDFIELD:
			return new Vektor(xy, 0.0, -12.0);
		case LEFT_MIDFIELD:
			return new Vektor(xy, -20.0, -6.0);
		case RIGHT_MIDFIELD:
			return new Vektor(xy, 20.0, -6.0);
		case LEFT_ATTACKER:
			return new Vektor(xy, -10.0, -2.0);
		case CENTER_ATTACKER:
			if (selfKickOff)
				return new Vektor(xy, 0.0, -3.1);
			else
				return new Vektor(xy, 0.0, -9.0);
		case RIGHT_ATTACKER:
			return new Vektor(xy, 10.0, -2.0);
		default:
			return new Vektor(xy, 25.0, 25.0);
		}
	}
	
	public static Vektor getFormationPosition(ROLE role, boolean selfKickOff) {

		int xy = Vektor.XY;

		switch (role) {
		case GOALIE:
			return new Vektor(xy, 0.0, -50 + SIZE_OF_MOVE);
		case INLE_BACK_FOUR:
			return new Vektor(xy, -7.0, -15.0 + SIZE_OF_MOVE);
		case INRE_BACK_FOUR:
			return new Vektor(xy, 7.0, -15.0 + SIZE_OF_MOVE);
		case LEFT_BACK_FOUR:
			return new Vektor(xy, -20.0, -15.0 + SIZE_OF_MOVE);
		case RIGHT_BACK_FOUR:
			return new Vektor(xy, 20.0, -15.0 + SIZE_OF_MOVE);
		case CENTER_MIDFIELD:
			return new Vektor(xy, 0.0, -12.0 + SIZE_OF_MOVE);
		case LEFT_MIDFIELD:
			return new Vektor(xy, -20.0, -6.0 + SIZE_OF_MOVE);
		case RIGHT_MIDFIELD:
			return new Vektor(xy, 20.0, -6.0 + SIZE_OF_MOVE);
		case LEFT_ATTACKER:
			return new Vektor(xy, -10.0, -2.0 + SIZE_OF_MOVE);
		case CENTER_ATTACKER:
			if (selfKickOff)
				return new Vektor(xy, 0.0, -3.1 + SIZE_OF_MOVE);
			else
				return new Vektor(xy, 0.0, -9.0 + SIZE_OF_MOVE);
		case RIGHT_ATTACKER:
			return new Vektor(xy, 10.0, -2.0 + SIZE_OF_MOVE);
		default:
			return new Vektor(xy, 25.0, 25.0 + SIZE_OF_MOVE);
		}
	}

	/**
	 * 
	 * @param numberPlayer - cislo hraca
	 * @param positionBall - pizicia lopty
	 * @param maxY - 
	 * @param isBallPossition - mame loptu v pozicii
	 * @param formationType - mame loptu v pozicii
	 * formacia 1 - utocna 
	 * formacia 0 - obranna
	 * @return
	 */
	public static Vektor getStrategicPosition(int numberPlayer,
			Vektor positionBall, double maxY, boolean isBallPossition,
			double maxXpercentage, FORMATION formationType) {
		
		
		if (formationType == FORMATION.UNKNOWN) {
			formationType = currentFormation;
		}
		// 0 - unknow
		// 1 - attack
		// 2 - defense
		// 3 - attack_evo
		// 4 - defense_evo
		// 5 - max_offensive
		// 6 - max_defensive
		int formationIndex = 0;
		switch(formationType) {
		case ATTACK: formationIndex = 0; break;
		case DEFENSE: formationIndex = 1; break;
		case ATTACK_EVO: formationIndex = 2; break;
		case DEFENSE_EVO: formationIndex = 3; break;
		case MAX_OFFENSIVE: formationIndex = 4; break;
		case MAX_DEFENSIVE: formationIndex = 5; break;
		case ATTACK1: formationIndex = 6; break;
		case DEFENSE1: formationIndex = 7; break;
		
		}
		PlayerFormationInfo12 PlayerFormationInfo12 = formationList.get(
				formationIndex).get(numberPlayer - 1);
		double x = PlayerFormationInfo12.getHomePosition().getX()
				+ positionBall.getX() * PlayerFormationInfo12.getAttractionX();
		double y = PlayerFormationInfo12.getHomePosition().getY()
				+ positionBall.getY() * PlayerFormationInfo12.getAttractionY();

		// do not move too much to the side 
		if (Math.abs(x) > 0.5 * maxXpercentage * PITCH_WIDTH) {
			x = Math.signum(x) * 0.5 * maxXpercentage * PITCH_WIDTH;
		}

		if ((PlayerFormationInfo12.isBehindBall() == true)
				&& (y > positionBall.getY())) {
			y = positionBall.getY();
		}

		if (y > PlayerFormationInfo12.getMaxY()) {
			y = PlayerFormationInfo12.getMaxY();
		} else {
			if (y < PlayerFormationInfo12.getMinY()) {
				y = PlayerFormationInfo12.getMinY();
			}
		}

		if (y > maxY) {
			y = maxY;
		}
		//if(numberPlayer == 9)
		//System.out.println("Pozicia" + x + ";" + y);
		
		return new Vektor(Vektor.XY,x, y);
	}
	
	
  
  
  /**
   * This method decides which hetero-playertype will be associated with the
   * player with number i
   * 
   * @param i -
   *            the number of the player
   * @param types -
   *            a list containing all available types 3 times, initially.
   *            Selected type will be removed!
   * @return the PConf, which was selected!
   */
  public static PConf[] getPConfForPlayers(PlayerTypeAnalyzer pta) {

    PConf[] all = pta.getAllPConf();
    PConf[] resultPConf = new PConf[11];

    int pcSize = pta.getPcSize();
    int ptypeIsAv[] = pta.getPtypeIsAv();

    // Ranked Values from PConf
    // KM: Kickable Margin
    // DP: Dash Power Rate
    // IM: Inertia Moment
    // St: Extra Stamina
    // int ranked_KM[] = pta.getRanked_KM();
    int ranked_DP[] = pta.getRanked_DP();
    int ranked_St[] = pta.getRanked_St();
    // int ranked_Fast[] = pta.getRanked_Fast();
    // int ranked_KM_IM[] = pta.getRanked_KM_IM();
    // int ranked_KM_St[] = pta.getRanked_KM_St();
    int ranked_DP_St[] = pta.getRanked_DP_St();
    int ranked_1DP_2St[] = pta.getRanked_1DP_2St();
    int ranked_2DP_1St[] = pta.getRanked_2DP_1St();
    int ranked_KM_DP_St[] = pta.getRanked_KM_DP_St();

    // Player assignment

    // Set Goalie
    resultPConf[0] = all[0].cloned();
    ptypeIsAv[0]++;

    // Set Player 10
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_DP[i]] < 3) {
        resultPConf[9] = all[ranked_DP[i]].cloned();
        ptypeIsAv[ranked_DP[i]]++;
        break;
      }

    // Set Player 4
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_DP[i]] < 3) {
        resultPConf[3] = all[ranked_DP[i]].cloned();
        ptypeIsAv[ranked_DP[i]]++;
        break;
      }

    // Set Player 7
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_KM_DP_St[i]] < 3) {
        resultPConf[6] = all[ranked_KM_DP_St[i]].cloned();
        ptypeIsAv[ranked_KM_DP_St[i]]++;
        break;
      }

    // Set Player 9
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_DP_St[i]] < 3) {
        resultPConf[8] = all[ranked_DP_St[i]].cloned();
        ptypeIsAv[ranked_DP_St[i]]++;
        break;
      }

    // Set Player 11
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_2DP_1St[i]] < 3) {
        resultPConf[10] = all[ranked_2DP_1St[i]].cloned();
        ptypeIsAv[ranked_2DP_1St[i]]++;
        break;
      }

    // Set Player 3
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_DP[i]] < 3) {
        resultPConf[2] = all[ranked_DP[i]].cloned();
        ptypeIsAv[ranked_DP[i]]++;
        break;
      }

    // Set Player 6
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_1DP_2St[i]] < 3) {
        resultPConf[5] = all[ranked_1DP_2St[i]].cloned();
        ptypeIsAv[ranked_1DP_2St[i]]++;
        break;
      }

    // Set Player 8
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_1DP_2St[i]] < 3) {
        resultPConf[7] = all[ranked_1DP_2St[i]].cloned();
        ptypeIsAv[ranked_1DP_2St[i]]++;
        break;
      }

    // Set Player 2
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_St[i]] < 3) {
        resultPConf[1] = all[ranked_St[i]].cloned();
        ptypeIsAv[ranked_St[i]]++;
        break;
      }

    // Set Player 5
    for (int i = 0; i < pcSize; i++)
      if (ptypeIsAv[ranked_St[i]] < 3) {
        resultPConf[4] = all[ranked_St[i]].cloned();
        ptypeIsAv[ranked_St[i]]++;
        break;
      }

    pta.setPtypeIsAv(ptypeIsAv);
    return resultPConf;
  }
}
